/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufc.quixada.adrs.comandos.supervisor;

import br.ufc.quixada.adrs.interfaces.Comando;
import br.ufc.quixada.adrs.model.Administrador;
import br.ufc.quixada.adrs.service.AdministradorService;
import br.ufc.quixada.adrs.util.Msg;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Balthazar
 */
public class CmdReativarAdmin implements Comando {

    public String executa(HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession(true);

        AdministradorService ps = new AdministradorService();
        Administrador prod = ps.getAdministradorByUsuarioIdToAtivarConta(Long.parseLong(request.getParameter("id")));

        if (ps.reativarContaAdmin(prod)) {
            session.setAttribute("sucesso", Msg.ACCOUNT_SUCCESSFULLY_RECOVERED);
        } else {
            session.setAttribute("erro", Msg.OPERATIONAL_ERROR_RECOVERING_ACCOUNT);
        }
        return new CmdCarregarAdminsExcluidos().executa(request, response);
    }
}
